package com.demo.project_template.controller;

import com.demo.project_template.entity.UserGreet;
import com.demo.project_template.service.UserGreetService;
import com.demo.project_template.vo.response.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *     用户打招呼用语
 *  前端控制器
 * </p>
 *
 * @author 杨玉龙
 * @since 2024-08-21 11:53:54
 */
@Api(tags = "打招呼用语")
@RestController
@RequestMapping("/userGreet")
public class UserGreetController {
    @Resource
    private UserGreetService userGreetService;

    @ApiOperation(value = "查询打招呼用语列表")
    @GetMapping(value = "/list")
    public R<List<UserGreet>> list(){
        return R.success(userGreetService.list());
    }

    @ApiOperation(value = "添加打招呼用语")
    @PostMapping(value = "/add")
    public R<?> add(@RequestBody UserGreet userGreet){
        userGreetService.save(userGreet);
        return R.success();
    }

    @ApiOperation(value = "修改打招呼用语")
    @PostMapping(value = "/update")
    public R<?> update(@RequestBody UserGreet userGreet){
        userGreetService.updateById(userGreet);
        return R.success();
    }

    @ApiOperation(value = "删除打招呼用语")
    @DeleteMapping(value = "/id")
    public R<?> delete(@RequestParam Long id){
        userGreetService.removeById(id);
        return R.success();
    }
}
